package com.yang.designmode.flyweight;
// 客户端调用
public class Client {
    public static void main(String[] args) {
        FlyweightFactory factory = new FlyweightFactory();

        Flyweight f1 = factory.getFlyweight("A");
        Flyweight f2 = factory.getFlyweight("B");
        Flyweight f3 = factory.getFlyweight("A"); // 共享已有对象

        f1.operation("X");
        f2.operation("Y");
        f3.operation("Z");

        System.out.println("实际创建的享元对象数量：" + factory.getTotalFlyweights());
    }
}

